class TextLabel {
  constructor(map) {
    this.map = map;
  }
  textLabelRender(options) {
    const { layer, layout, paint, isOpen, renderField } = options;
    if (isOpen) {
      Object.keys(layout).forEach((key) => {
        if (key === 'text-field') {
          const expression = ['get', renderField];
          this.map.setLayoutProperty(layer.labelLayer.id, key, expression);
        } else {
          this.map.setLayoutProperty(layer.labelLayer.id, key, layout[key]);
        }
      });
      Object.keys(paint).forEach((key) => {
        this.map.setPaintProperty(layer.labelLayer.id, key, paint[key]);
      });
    } else {
      this.map.setLayoutProperty(layer.labelLayer.id, 'visibility', 'none');
    }
  }
}
export default TextLabel;
